/*诊断模块化,编辑病人信息*/

//首页
var indexZhenduan;
//医嘱单对应诊断加载
function adviceDiagnose(cbm01,tabid){
	debugger;
	var target = $("#"+tabid).find("tbody");
	params = {};
	params.cbm01 = cbm01;
	//获取病人诊断的信息
	$.ajax(
	{
	data : params,
	url : rootUrl + "/treatment/getZhenduanShouye1",
	type : 'get',
	dataType : 'json',
	success : function(data)
		{
			var list = data.list;
			var advicezhenduanHtml="";
			for (var i = 0; i < list.length; i++) {
				advicezhenduanHtml +="<tr data-info='"+JSON.stringify(list[i])+"'>";
				var isnormal = list[i].vao07== 0 ?"初步诊断":"正常诊断";
				advicezhenduanHtml +="<td>"+isnormal+"</td>"; //诊断顺序
				advicezhenduanHtml +="<td>"+list[i].vao15+"</td>"; //诊断描述
				if(list[i].vao18 ==1){
					advicezhenduanHtml +="<td><input type='checkbox' checked disabled='disabled'/></td>"; //疑诊
				}else{
					advicezhenduanHtml +="<td><input type='checkbox'  disabled='disabled'/></td>"; //疑诊
				}
				advicezhenduanHtml +="<td>"+list[i].vaf01+"</td>"; //医嘱单
				if(tabid !='chufang_zhenduan_b'){
					debugger;
					if(!pinquiry){
						advicezhenduanHtml +='<td><input class="btn btn-transparent btn-min advice-edit" type="button" value="编辑 " /><span>|</span>';
						advicezhenduanHtml +='<input class="btn btn-transparent btn-min advice-del" type="button" value="删除 " />';
						if(list[i].infection == 1){
							advicezhenduanHtml +='<span>|</span><input class="btn btn-transparent btn-min advice-disease" type="button" value="传染病报告卡 " /></td>'; //操作
						}
						
					}
					
				}
				
				advicezhenduanHtml +="</tr>"
			}
			target.empty().append(advicezhenduanHtml);
			//编辑数据相同，展示诊断
			target.find(".advice-edit").off("click").on("click",function(){
				editAdviceDiagnose(data.list,cbm01)
			});
			target.find(".advice-disease").off("click").on("click",function(){
				checkDiagnoseDisease(data.list,cbm01)
			});
			target.find(".advice-del").off("click").on("click",function(){
				debugger;
				var datastr = $(this).parents("tr").attr("data-info");
				var dataobj = JSON.parse(datastr);
				layer.confirm('确定删除该诊断信息', {
					btn : [ '确定', '取消' ]
				// 按钮
				}, function() {
					delAdviceDiagnose(dataobj.vao01,cbm01);
					
				}, function() {

				});
			});
			
		}
	})
}
//删除诊断
function delAdviceDiagnose(vao01,cbm01){
	var url = rootUrl + "/treatment/deleteVao1ByVao01";
	var para = {
			vao01 : vao01
			};
	$.when($.post(url, para)).done(function(data) {
		if(data.result == "Success"){
			layer.msg('删除成功',
					{
					time : 1000,
					icon : 1,
					skin: 'layui-layer-msg1'
					});
			//刷新诊断信息
			adviceDiagnose(cbm01);
		}
	})
}
//编辑数据相同，展示诊断
function editAdviceDiagnose(data,cbm01){
	laytplUrl(myurl + "/module/shouye_table.html", data, function(data, html)
			{
				indexZhenduan = layer.open(
				{
				type : 1,
				scrollbar : false,
				title : "诊断信息",
				area :
				["80%", "80%"],
				shade : 0.3,
				//maxmin : true,
				content : html,
				closeBtn : 1,
				success : function()
				{
					$("select").select2(
					{
						language : "zh-CN"
					});
					//诊断顺序赋值
					diagnoseInAdvice();
					deleteTr();
					//addzhenduanSelect();
					$("#remove_action_zd").on("click", function()
					{
						layer.close(indexZhenduan);
					});
					$("#save_iagnose").on("click",function(){
						saveZhenduan("edit",cbm01);
					});
					$("#add_iagnose").on("click",function(){
						zhenduanCloneTr(cbm01);
					})
				}
				})
			});
}

function shouyeEvent()
{
	$('#shouye_btn').on("click", function()
	{
		if (isOwnchose)
		{
			var vac01 = $("#vac01").val();
			params = {};
			params.vac01 = vac01;
			//获取病人诊断的信息
			$.ajax(
			{
			data : params,
			url : rootUrl + "/treatment/getZhenduanShouye",
			type : 'get',
			dataType : 'json',
			success : function(data)
			{
				debugger;
				laytplUrl(myurl + "/module/shouye_table.html", data.list, function(data, html)
				{
					indexZhenduan = layer.open(
					{
					type : 1,
					scrollbar : false,
					title : "诊断信息",
					area :
					["80%", "80%"],
					shade : 0.3,
					//maxmin : true,
					content : html,
					closeBtn : 1,
					success : function()
					{
						$("select").select2(
						{
							language : "zh-CN"
						});
						deleteTr();
						//addzhenduanSelect();
						$("#remove_action_zd").on("click", function()
						{
							layer.close(indexZhenduan);
						});
						$("#save_iagnose").on("click",function(){
							saveZhenduan();
						})
						$("#add_iagnose").on("click",function(){
							zhenduanCloneTr();
						})
					}
					})
				});
			}
			});
		}
		else
		{
			layer.msg("请选择病人",
			{
			time : 2000,
			icon : 0,
			skin : 'layui-layer-msg0'
			});
		}
	})
}
//编辑数据增加下拉框
function addzhenduanSelect()
{
	$("#zhenduan_tbody tr").each(function(i, e)
	{
		//    		if(($(e).find(".shouye_yzd").text())=='0'){
		var id = $(e).find(".shouye_zdms").attr("id");
		zhenduaninputEvent(id);

		//    		}
	})
}
//增加行.传入医嘱单id
function zhenduanCloneTr(cbm01)
{
	var data={}
	if(cbm01){
		data.cbm01 = cbm01
	}
	laytplUrl(myurl + "/module/shouye_tr_clone.html",data, function(data, html)
	{
		$("#zhenduan_tbody").append(html);
		zhenduanindex++;
		var id = $(".shouye_zdms").last().attr("id");
		shouyeActiveId = id;
		diagnoseInAdvice(id);
		//zhenduaninputEvent(id);
		deleteTr();
		$("select").select2({});
	});
}
//删除行
function deleteTr()
{
	$(".shouye_cz").on("click", function()
	{
		$(this).parents("tr").remove();
	})
}
//首页诊断下拉
//input输入事件事件
function zhenduaninputEvent(id)
{
	var currentInput = $("#" + id).focus();
	/*按回车按钮后弹出下拉框*/
	currentInput.keydown(function(e)
	{
		var inputText = $(this).val();
		if (e.which === 13)
		{
			var that = this;
//			zhenduangetDropList(id);
			editDiagnoseIndex(id);

		}
	});

	$("#" + id).on("click", function()
	{//点击出现下拉
		var inputText = $(this).val();
		shouyeActiveId = id;
//		zhenduangetDropList(id);
		editDiagnoseIndex(id);
	})
}

/* 点击出现下拉框 */
function zhenduangetDropList(inputId)
{

	shouyeActiveId = inputId;
	var thisLeft = $("#" + inputId).position().left;
	var thisTop = $("#" + inputId).position().top;
	var thisheight = $("#" + inputId).parent().outerHeight();
	$(".selectDiv").slideDown();
	$(".selectDiv").css(
	{
	position : "absolute",
	left : thisLeft,
	top : thisTop + thisheight - 7 + "px",
	display : "block"
	})
	$("#refund").css(
	{
		"z-index" : 999
	})
	var shouyeobj =
	{
	"tree" : "zhenduan-tree",//第一个tab（常用诊断）的左边tree id
	"search_jibing" : "search_jibing",
	"chengyongzhenduan" : "shouye_xydqzd",
	"tree_table" : "zhenduan-tree-table"
	}
	banliruyuan_zhenduan(shouyeobj);
	keySearchJibingEvent1();
}

//保存诊断信息
function saveZhenduan(type,cbm01)
{
	debugger;
	var vao1 =[];
	var vac01 = $("#vac01").val();
	var vaa01 = $("#vaa01").val();
	//1过滤空行
	$("#zhenduan_tbody tr").each(function(i, ele)
	{
		if (!($(ele).find(".shouye_zdms").val()))
		{
			$(ele).find(".shouye_cz").trigger("click");
		}
		else
		{
			var obj =
			{};
			obj.vao07 = $(ele).find(".shouye_zdsx").val();//诊断顺序
			obj.vao15 = $(ele).find(".shouye_zdms").val();//诊断内容
			obj.cam01 = ($(ele).find(".shouye_zdms").attr("data-info") !="undefined") ? ($(ele).find(".shouye_zdms")
					.attr("data-info")) : "-1";//诊断内容id
			obj.bgp01 = $(ele).find(".shouye_zdyj").find("select option:selected").val();//诊断依据
			obj.ady01 = $(ele).find(".shouye_zdjg").find("select option:selected").val();//诊断结果
			if ($(ele).find(".shouye_yz").is(':checked'))
			{//疑诊
				obj.vao18 = 1;
			}
			else
			{
				obj.vao18 = 0;
			}
			obj.vaf01 = $(ele).find(".shouye_yzd").text();//医嘱单
			obj.vac01 = vac01;
			obj.vaa01 = vaa01;
			vao1.push(obj);
		}
	})
	//2数据合法性校验
	var url;
	var param;
	if(type=="edit"){
		url = rootUrl + "/treatment/saveZhenduanShouye1";
		param = {
				"vao1" : JSON.stringify(vao1),
				"cbm01" : vao1[0].vaf01
				}
	}else{
		url = rootUrl + "/treatment/saveZhenduanShouye"
		param = {
				"vao1" : JSON.stringify(vao1),
				"vac01" : vac01
				}
	}
	//3 数据持久化
	$.ajax(
	{
	data :param,
	url : url,
	type : 'post',
	dataType : 'json',
	success : function(data)
	{
		if (data)
		{
			if (data.result == 'Success')
			{
				layer.msg("诊断信息保存成功",
						{
						time : 2000,
						icon : 1,
						skin : 'layui-layer-msg1'
						});
				if(type=="edit"){
					//刷新诊断信息
					adviceDiagnose(cbm01);
				}
				layer.close(indexZhenduan);
			}
		}
		else
		{
			layer.alert("数据异常，请联系管理员！",
			{
				icon : 2
			});
		}
	}
	});

}
//诊断疾病搜索
function searchJibingEvent(id, tableid)
{

	/*layer.msg('查询中....', {icon: 16,shade: [0.1, '#393D49'],time:1*500});  
	>>>>>>> .r14896
	var text = $("#"+id).val();
	$.ajax({
		url : rootUrl + "/clidoctor/queryJibingByText",
		type : "get",
		dataType : 'json',
		data:{"txt":"%"+text+"%"},
		success : function(data) {
			debugger;
			if(data.list.length>0){
				laytplUrl(myurl+"/module/tree-table-jibing-search.html",data,function(data,html){
					$("#"+tableid).empty().append(html);
					$(".selectDiv").find("table tbody tr:eq(0)").addClass("choseedTr");
				});
			}else{
				$("#"+tableid).empty();
			}
		}
	});
	
	 */
	var text = $("#" + id).val();
	var reg= /^[A-Za-z]+$/; //判断是字母
	if (reg.test(text)){
		text = text.toLowerCase();
	}
	var url1 = solrUrl + "/menzhenzhenduan";
	var params =
	{};
	params.q = "(bak02:*" + text + "* OR bak05:*" + text + "* OR bak06:*" + text + "* OR abbrp:*" + text + "* OR abbrw:*" + text + "*)";
	params.fl = 'bak01,bak02,bak05,bak06,abbrp,abbrw,abw01,cam01';
	params.url = url1;
	params.rows = 30;
	$.ajax(
	{
	url : rootUrl + "/doctoradvice/queryAdviceBySolr",
	type : "post",
	dataType : 'json',
	data :
	{
		params : JSON.stringify(params)
	},
	success : function(data)
	{
		if (data.list && data.list.length > 0)
		{
			laytplUrl(myurl + "/module/tree-table-jibing-search.html", data, function(data, html)
			{
				$("#" + tableid).empty().append(html);
				$(".selectDiv").find("table tbody tr:eq(0)").addClass("choseedTr");
			});
		}
		else
		{
			$("#" + tableid).empty();
		}
	}
	});
}
//诊断疾病回车搜索
function keySearchJibingEvent()
{
	/*$("#search_jibing").keydown(function (e) {
		if (e.which === 13) {
			searchJibingEvent('search_jibing','ruyuan-tree-table');
		}
	});*/
	$("#search_jibing").on("input", function(e)
	{
		searchJibingEvent('search_jibing', 'ruyuan-tree-table');
	});

}
//诊断疾病回车搜索
function keySearchJibingEvent1()
{
	$("#search_jibing1").on("input", function(e)
	{
		searchJibingEvent('search_jibing1', 'zhenduan-tree-table');
	});

}




function closeChangeTdDiv_zhenduan1()
{
	$("#shouye_zhenduan").hide();
	$("#banliruyuan_zhenduan").hide();
}

/* 诊断下拉框 */
//function xySelectDiv()
//{
//	$(".bootstrap-tagsinput").on("click", function()
//	{
//		debugger;
//		var e = arguments.callee.caller.arguments[0] || event;
//		if (e && e.stopPropagation)
//		{
//			// this code is for Mozilla and Opera
//			e.stopPropagation();
//		}
//		else if (window.event)
//		{
//			// this code is for IE 
//			window.event.cancelBubble = true;
//		}
//		var thisLeft = $(this).position().left;
//		var thisTop = $(this).position().top;
//		var thisheight = $(this).outerHeight() + 1;
//		$(".selectDiv").slideDown();
//		$(".selectDiv").css(
//		{
//		position : "absolute",
//		left : thisLeft,
//		top : thisTop + thisheight + "px",
//		display : "block"
//		})
//		$("#refund").css(
//		{
//			"z-index" : 999
//		})
//		var obj =
//		{
//		"tree" : "bangliruyuan-tree",
//		"search_jibing" : "search_jibing",
//		"chengyongzhenduan" : "blry_xydqzd",
//		"tree_table" : "ruyuan-tree-table"
//		}
//		banliruyuan_zhenduan(obj);
//		keySearchJibingEvent();
//		// hideDiv(".selectDiv");
//	})
//}
// 办理入院诊断数据加载
function banliruyuan_zhenduan(obj)
{
	// 加载疾病
	/*var url = rootUrl + "/treatment/jibingList";
	var params =
	{};
	$.get(url, params, function(data)
	{*/
		var list = jibingList;
		$('#' + obj.tree).treeview(
		{
			data : list
		});//办理入院
		$('#' + obj.tree).on('nodeSelected', function(event, data)
		{
			$("#" + obj.search_jibing).val('');
			// 查询疾病详细项目列表
			ruyuanXiangxiList(data['id'], obj);
		});
//	});
	var data = ruyuanbingrenVaoList;
	if (data)
	{
		laytplUrl(myurl + "/module/zhenduan_table.html", data, function(data, html)
		{
			$("#" + obj.chengyongzhenduan).html(html);
			$(".selectDiv").find("table tbody tr:eq(0)").addClass("choseedTr");
		});
	}

}
// 入院诊断疾病-根据cag01查询详细
function ruyuanXiangxiList(bah01, obj)
{
	var url = rootUrl + "/treatment/jibingInfo";
	var params =
	{};
	params.bah01 = bah01;
	$.get(url, params, function(data)
	{
		if (data)
		{
			laytplUrl(myurl + "/module/tree-table-jibing.html", data, function(data, html)
			{
				$("#" + obj.tree_table).empty().append(html);
				$(".selectDiv").find("table tbody tr:eq(0)").addClass("choseedTr");
			});
		}
	});
}

/***************************************编辑病人信息****************************************************************************************/
var patient_info_layer;
function loadInitData(obj)
{
	var vac01=$("#vac01").val();
	if (!vac01||vac01 == 'null')
	{
		layer.msg("请选择要修改的病人",
				{
				time : 2000,
				icon : 0,
				skin : 'layui-layer-msg0'
				});
		$("#patientInfo1").removeAttr("disabled");
	}
	else
	{
		var url = rootUrl + "/cliparamter/clihomepagepatientbasicinfo";
		var para =
		{
			VAA07 : vac01
		};
		$.when($.post(url, para)).done(function(data)
		{
			if (data.list.length > 0)
			{
				var list = data.list[0]
				obj.pdata = list;
				debugger;
				laytplUrl(myurl + "/module/edit_patient_info.html", obj, function(data, html)
				{
					
				   patient_info_layer = layer.open(
					{
					type : 1,
					scrollbar : false,
					title : "病人信息",
					area :
					["60%", "80%"],
					shade : 0.1,
					// maxmin : true,
					content : html,
					closeBtn : 1,
					success : function()
					{
						debugger;
						 //年龄日期单位事件绑定；
						 ageChangeBind("p_vaa10","p_vaa12","p_aau01","p_vaa15");
						 afterReadyInit(list);
						 layer.closeAll('dialog');
						$("#edit_btn_reomve").on("click", function() {
							layer.close(patient_info_layer);
						});
					}
					})

				});

			}

		})
	}

}

function loadInitData_ry(obj)
{
	var url = rootUrl + "/cliparamter/clihomepagepatientbasicinfo";
	var para =
	{
		VAA07 : $("#vac01").val()
	};
	$.when($.post(url, para)).done(function(data)
	{
		if (data.list.length > 0)
		{
			var list = data.list[0]
			obj.pdata = list;
			obj.footer = "no";
			debugger;
			laytplUrl(myurl + "/module/edit_patient_info.html", obj, function(data, html)
			{

				 //年龄日期单位事件绑定；
				ageChangeBind("p_vaa10","p_vaa12","p_aau01","p_vaa15");
				$("#patient_info_t").empty().append(html);
				afterReadyInit(list);
				 layer.closeAll('dialog');
			});

		}

	})

}

// 模板或者弹出层成功之后的事情
function afterReadyInit(list){
	$("#function_btn_1").removeAttr("disabled");
	if(list.abq02){
//		$("#p_abq02").val(list.abq02).trigger("change");//民族
//		
//	}else{
		
		$("#p_abq02").val("汉族").trigger("change");//民族
//	}
	}
	$("#p_vaa19").val(list.vaa19).trigger("change");//险种名称
	$("#p_bdx02").val(list.bdx02).trigger("change");//了解途径
	$("#p_vac16").val(list.vac16).trigger("change");//职业
	$("#p_ack01").val(list.ack01).trigger("change");//婚姻状况
	$("#p_vaa38").val(list.vaa38).trigger("change");//文化程度
	if(list.bak05){
		$("#bak05").val(list.bak05).trigger("change");//疾病分类
	}
	$("#p_bdp02").val(list.bdp02).trigger("change");//病人类别
	$("#p_aau01").val(list.aau01).trigger("change")//年龄单位
	$("#p_aaz02").val(list.aaz02).trigger("change")//联系人关系
	$("#p_vaa12").val(list.vaa12?moment(list.vaa12).format("YYYY-MM-DD HH:mm:ss"):'');//出生日期
	
//	if(list.acc02){
//		$("#p_acc02").val(list.acc02).trigger("change");//国籍
//		
//	}else{
		$("#p_acc02").val("中国").trigger("change");//国籍
		
//	}
	
	$("#edit_patient_form_info").find("select[id!='p_aau01']").select2(
	{
		language : "zh-CN"
	})
	if(list.vcj20){
		var p_v = list.vcj20.split(":")[0];
		var s_v = list.vcj20.split(":")[1];
		$("#vcj20_p").val(p_v);
		$("#vcj20_s").val(s_v).trigger("change");
			}
	$("#patientInfo1").removeAttr("disabled");
}

//点击更多或收起更多按钮
function showOrHideMore(that)
{
	if ($(that).text().trim() == "收起更多")
	{
		$("#edit_patient_form_info").find(".may-hidden-ele").hide();
		$(that).text("查看更多");
	}
	else
	{
		$("#edit_patient_form_info").find(".may-hidden-ele").show();
		$(that).text("收起更多");
	}
}

//保存病人信息

function saveEditPatientInfo(){
	debugger;
	  var ivac01 = $("#vac01").val();
	  var num =  $('#p_vaa15').val();
	 if(!$("#p_vaa05").val() ||!$("#p_vaa10").val()){
		 if(!$("#p_vaa05").val()){
			 
			 layer.tips('请填写姓名', '#p_vaa05', {
				 tipsMore: true
			 });
		 }else if(!$("#p_vaa10").val()){
			 
			 layer.tips('请填写年龄', '#p_vaa10', {
				 tipsMore: true
			 });
		 }else if(!$("#p_vaa05").val() &&!$("#p_vaa10").val()){
			 layer.tips('请填写姓名', '#p_vaa05', {
				 tipsMore: true
			 });
			 layer.tips('请填写年龄', '#p_vaa10', {
				 tipsMore: true
			 });
			 
		 }
		 return false;
	 }
	 if (!!num) {
      	if(!verfyCertificat(num)){
      		layer.tips('身份证不正确，请重新输入','#p_vaa15');
      		return false;
      	}
	 }
		layer.msg('修改病人信息中....', {
			icon: 16,
			shade: [0.1, '#393D49'],
			time:0,
			success:function(){
				$("#edit_btn_save").attr("disabled","disabled");
			}
		});  
		//处理form中的radio
		var radioArr = [
		                {classN:"radioabw01",id:"p_abw01"},
		                {classN:"radiovac06",id:"p_vac06"},
		                {classN:"radiovcj20",id:"p_vcj20"},
		                {classN:"radiovac40",id:"p_vac40"}
		                ];
		for(var i=0;i<radioArr.length;i++){
			
			var abw01Val = $("."+radioArr[i].classN).find("input:checked").val();
			$("#"+radioArr[i].id).val(abw01Val);
		}
		$("#p_bce01").val(bce01);
		$("#p_bce03").val(bce03);
		$("#p_bck01").val(bck01);
		$("#p_bck03").val($("#departmentList").val());
		$("#p_vac01").val($("#vac01").val());
		$("#p_vaa01").val($("#vaa01").val());
		debugger;
		//血糖处理
	    var vcj20_v = $("#vcj20_p").val();
	    if(vcj20_v){
	    	
	    	$("#vcj20_1").val(vcj20_v+":"+$("#vcj20_s").val())
	    	
	    }
	    //获取病人信息的数据
		var data = $("#edit_patient_form_info").serializeArray(); //自动将form表单封装成json  
		for(var i = 0;i<data.length;i++)
		 {
			 //地址
			 var temp = data[i];
			 if(temp.name=="vac19")
			 {
				 data.push({name:"vaa33",value:temp.value});
			 }
			 //电话
			 if(temp.name=="vaa35")
			 {
				 data.push({name:"vac20",value:temp.value});
			 }
			 //工作单位
			 if(temp.name=="vac27")
			 {
				 data.push({name:"vaa47",value:temp.value});
			 }
		 }
		var mydata = JSON.stringify(data);
		console.table(mydata);
 		$.ajax({
			type : 'post',
//			url : rootUrl + '/basicinformationquery/updatehoratevac1modify',
			url : rootUrl + '/basicinformationquery/updateVaaVacVcj',
			data : {
				'mydata' : mydata
			},
			dataType : "json",
			success : function(data) {
				if(data.result=="Success" || data.result=="SUCCESS"){
					$("#edit_btn_save").removeAttr("disabled");
					layer.msg("修改成功", {icon:1,skin:'layui-layer-msg1',time:1500});
					refreshListHouzhen();
					refreshListJiezhen();
//					$("#vac01").val(ivac01);
					reloadPatientInfo(ivac01);
					layer.close(patient_info_layer);
				}else{
					layer.msg(data.resultMsg, {
						icon: 2,
						skin:'layui-layer-msg2',
						time:3000,
						end:function(){
							$("#edit_btn_save").removeAttr("disabled");
						}
					});
					$("#vac01").val(ivac01);

				}
			}
		});
		return false;
}
//加载病人信息下拉数据
function deitPatinetInfo(ishospital)
{
	$("#patientInfo1").attr("disabled",true);
	
	$("#function_btn_1").attr("disabled",true);
	layer.msg('加载中....', {icon: 16,skin: 'layui-layer-msg16',shade: [0.1, '#393D49'],time:0}); 
	var guoji ="";
	var minzu  ="";
	var liaojietujing  ="";
	var zhiye  ="";
	var hunyinzhuangkuang  ="";
	var xueli  ="";
	var jibingfenlei  ="";
	var xianzhongmingc = "";
	var bingrenleibie="";
	var lianxirguanxi="";
	var iax05="医疗保险参保类型";
	debugger;
	$.when(

	//国籍
	$.get(rootUrl + "/clidoctor/selectDataByScriptId",
	{
	ID : 549,
	paramStr : '{}'
	}, function(json)
	{
		if (json.result == "Success")
		{
//			guoji = "<option value='0'>--请选择--</option>";
			for (var i = 0; i < json.list.length; i++)
			{
//				guoji += $("<option>").val(json.list[i].acc02).text(json.list[i].acc02);
				guoji += '<option value='+json.list[i].acc02+'>'+json.list[i].acc02+'</option>';
			}
		}
	}),
	//民族
	$.get(rootUrl + "/clidoctor/selectDataByScriptId",
	{
	ID : 39,
	paramStr : '{}'
	}, function(json)
	{
		if (json.result == "Success")
		{
//			$("#p_abq02").empty();
//			minzu= $("<option>").val(0).text("--请选择--");
//			$("#p_abq02").append(option);
			for (var i = 0; i < json.list.length; i++)
			{
//				minzu += $("<option>").val(json.list[i].abq02).text(json.list[i].abq02);
				minzu += '<option value='+json.list[i].abq02+'>'+json.list[i].abq02+'</option>';
			}
		}
	}), 
	//获取了解途径
	
	$.get(rootUrl + "/clidoctor/selectDataByScriptId",
	{
	ID : 617,
	paramStr : '{}'
	}, function(json)
	{
		if (json.result == "Success")
		{
//			$("#p_bdx02").empty();
			liaojietujing = $("<option>").val(0).text("--请选择--");
//			$("#p_bdx02").append(liaojietujing);
			for (var i = 0; i < json.list.length; i++)
			{
//				liaojietujing += $("<option>").val(json.list[i].bdx02).text(json.list[i].bdx02);
				liaojietujing += '<option value='+json.list[i].bdx02+'>'+json.list[i].bdx02+'</option>';
			}
		}
	}),
	//职业
	$.get(rootUrl + "/clidoctor/selectDataByScriptId",
			{
			ID : 616,
			paramStr : '{}'
			}, function(json)
			{
				if (json.result == "Success")
				{
//					$("#p_vac16").empty();
					zhiye = $("<option>").val(0).text("--请选择--");
//					$("#p_vac16").append(zhiye);
					for (var i = 0; i < json.list.length; i++)
					{
//						zhiye += $("<option>").val(json.list[i].aat01).text(json.list[i].aat02);
						zhiye += '<option value='+json.list[i].aat01+'>'+json.list[i].aat02+'</option>';
					}
				}
			}),
			//婚姻状态
			$.get(rootUrl + "/clidoctor/selectDataByScriptId",
					{
					ID : 593,
					paramStr : '{}'
					}, function(json)
					{
						if (json.result == "Success")
						{
//							$("#p_ack01").empty();
							hunyinzhuangkuang = $("<option>").val(0).text("--请选择--");
//							$("#p_ack01").append(hunyinzhuangkuang);
							for (var i = 0; i < json.list.length; i++)
							{
//								hunyinzhuangkuang += $("<option>").val(json.list[i].ack01).text(json.list[i].ack02);
								hunyinzhuangkuang += '<option value='+json.list[i].ack01+'>'+json.list[i].ack02+'</option>';
							}
						}
					}),
					//学历
					$.get(rootUrl + "/clidoctor/selectDataByScriptId",
							{
								ID : 43,
								paramStr : '{}'
							}, function(json) {
						
						if (json.result == "Success") {
							xueli="<option value=''>请选择</option>";
							for (var i = 0; i < json.rows.length; i++) {
								xueli += "<option value='"+json.rows[i].aay02+"'>"+json.rows[i].aay02+"</option>";
							}
						}
					}),
					$.get(rootUrl+"/clidoctor/selectDataByScriptId",{ID:5250,paramStr:'{}',rownum:100}, function(json){
						if(json.result=="Success"){
							for(var i=0;i<json.rows.length;i++){
//								if(bak05==json.rows[i].bah03){
//									jibingfenlei += "<option value='"+json.rows[i].bah03+"'>"+json.rows[i].bah03+"</option>";
//								}else{
//									jibingfenlei += "<option value='"+json.rows[i].bah03+"'>"+json.rows[i].bah03+"</option>";
//								}
								jibingfenlei += "<option value='"+json.rows[i].bah03+"'>"+json.rows[i].bah03+"</option>";
							}
						}
					}),
					$.get(rootUrl+"/clidoctor/selectDataByScriptId",
							{
						ID:10000003,
						paramStr:'{iax05:"'+iax05+'"}'
							}, function(json) {
						
								xianzhongmingc="<option value=''>请选择</option>";
								if(json.result=="Success"){
									for (var i = 0; i < json.rows.length; i++) {
										xianzhongmingc += "<option id='"+json.rows[i].bdp02+"' value='"+json.rows[i].vaa19+"'>"+json.rows[i].vaa19+"</option>";
									}
								}
					}),
					$.get(rootUrl + "/clidoctor/selectDataByScriptId",
							{
							ID : 4169,
							paramStr : '{}'
							}, function(json)
							{
								if (json.result == "Success")
								{
									for (var i = 0; i < json.list.length; i++)
									{
										bingrenleibie += "<option value='"+json.list[i].bdp02+"'>"+json.list[i].bdp02+"</option>";
										
									}
									loadabc021();
								}
							}),
					//联系人关系
					$.get(rootUrl + "/clidoctor/queryFamilyRelation",
							{
						params:{params:{}}
							}, function(json)
							{
								debugger;
								if (json.result == "Success")
								{
									for (var i = 0; i < json.list.length; i++)
									{
										lianxirguanxi += "<option value='"+json.list[i].aaz02+"'>"+json.list[i].aaz02+"</option>";
										
									}
								}
							})
					


		

	).done(function(data, data1)
	{
		debugger;
		var obj ={};
		obj.guoji = guoji;
		obj.minzu = minzu;
		obj.liaojietujing = liaojietujing;
		obj.zhiye = zhiye;
		obj.hunyinzhuangkuang = hunyinzhuangkuang;
		obj.xueli = xueli;
		obj.jibingfenlei = jibingfenlei;
		obj.xianzhongmingc = xianzhongmingc;
		obj.bingrenleibie = bingrenleibie;
		obj.lianxirguanxi = lianxirguanxi;
		if(ishospital){
			loadInitData_ry(obj);
		}else{
			loadInitData(obj);
		}
	})
}
function loadabc021(obj){
	var bdp02text = $("#p_bdp02").find("option:selected").text();
	if(!!bdp02text){
		
		if($("#p_abc02").length>0){
			$.get(rootUrl + "/clidoctor/selectDataByScriptId",{ID:5240,paramStr:'{BDP02:"'+bdp02text+'"}'}, function(json){
				debugger;
				if(json.result=="Success"){
//			for(var i=0;i<json.rows.length;i++){
					
					$("#p_abc02").val(json.rows[0].abc02);
					
//			}
				}
			});
		}
	}
}


function changeleibie1()
{
	debugger;
	var bdp02 = $("#p_vaa19").find("option:selected").attr("id");
	$("#p_bdp02").val(bdp02).trigger("change");
}